package study.optional.实战练习;

import java.util.Optional;
import java.util.Properties;
import java.util.Set;

/**
 * @Author 刘伟涛
 * @Date 2023/7/6 9:32
 **/
public class Demo01 {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.setProperty("a","5");
        properties.setProperty("b","ture");
        properties.setProperty("c","-3");
        properties.setProperty("d","张飞");
        /*Set<String> strings = properties.stringPropertyNames();
        System.out.println("stringPropertyNames:"+strings);*/

        /*Set<Object> objects = properties.keySet();
        System.out.println("keySet:" + objects);*/
        Set<String> strings = properties.stringPropertyNames();
        strings.stream().map(x->stringTOInteger(properties.getProperty(x))).forEach(y-> System.out.println("返回结果："+y));

    }
    public static Integer stringTOInteger(String str){
        return Optional.ofNullable(str)
                .flatMap(OptionalUtility::stringToInt)
                .filter(i -> i > 0)
                .orElse(0);
    }
}
